package com.eudon.design_pattern.behavioral.chain;

import com.eudon.design_pattern.behavioral.chain.filter.PoliticsWordFilter;
import com.eudon.design_pattern.behavioral.chain.filter.RacistWordFilter;
import com.eudon.design_pattern.behavioral.chain.filter.SexyWordFilter;
import com.eudon.design_pattern.behavioral.chain.filter.WordFilter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author eudon
 * @description 敏感词过滤器链
 * @date 2025/9/2
 * @email syd19970616@gmail.com
 * @address <a href="https://gitee.com/eudon">Gitee</a>
 */
public class WordFilterChain {
    private static List<WordFilter> filters = new ArrayList<>();

    static void init() {
        filters.add(new SexyWordFilter());
        filters.add(new PoliticsWordFilter());
        filters.add(new RacistWordFilter());
    }

    public static void doFilter(String text) {
        for (WordFilter filter : filters) {
            text = filter.filter(text);
        }
    }
}
